// 引入全局声明
/// <reference lib="es2021.promise" />

// 假设有两个异步函数
function asyncFunction3(): Promise<string> {
    return new Promise(resolve => setTimeout(() => resolve('Result from asyncFunction3'), 1000));
}

function asyncFunction4(): Promise<number> {
    return new Promise((_, reject) => setTimeout(() => reject('Error from asyncFunction4'), 500));
}

// 使用 any 扩展方法
const promises2 = [asyncFunction3(), asyncFunction4()];

Promise.any(promises2)
    .then(result => {
        console.log(`Resolved: ${result}`);
        // 处理至少一个 Promise 被 resolved 的逻辑
    })
    .catch(errors => {
        console.error(`Rejected with all errors: ${errors}`);
        // 处理所有 Promise 都被 rejected 的逻辑
    });
